<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>时段护理卡模板管理</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
		fieldset{
			display:inline-block;width:100%;
		}
		.ui-field-contain fieldset div.ui-input-text{
			float:left;
			width:50%;
		}
		.pbuttons{
			width:43%;display: inline-block;margin-left:10px;
		}
		.pbuttons .ui-btn{
			margin-bottom:25px;
		}
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$("#inputForm").validate({
				rules:{
	                "retail_price": "ifMoney"
	            },
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			$("#retail_price").change(function(){
				$("#real_cost").val($(this).val());
			});
			var duration = '${storeCardTemplateDuration.duration}';
			$("#duration option[value='"+duration+"']").attr("selected",true);
			$("#duration").selectmenu('refresh');
			addParentPageNo();
		});
		function addParentPageNo() {
			var id = '${storeCardTemplateDuration.id}';
			var pageNo = 1;
			if(id != "" && sessionStorage.parentPageNo) {
				pageNo = sessionStorage.parentPageNo;
			}
			$("#pageNo").val(pageNo);
			var href = "${ctx}/base/storeCardTemplateDuration/?pageNo=" + pageNo + "&currentSelectId=" +id;
			$("#return").attr("href", href);
		}
	</script>
</head>
<body>
	<form:form id="inputForm" class="form-input" modelAttribute="storeCardTemplateDuration" action="${ctx}/base/storeCardTemplateDuration/save" method="post">
		<form:hidden path="id"/>
		<input type="hidden" id="pageNo" name="pageNo" />
		<div class="icon-buttons">
			<a id="return" data-role="button" data-inline="true" data-icon="back" data-iconpos="notext"  href="">返回</a>
			<input type="submit" value="保 存" data-icon="check" data-iconpos="notext"  data-inline="true"/>
		</div>
		<tags:message content="${message}"/>
		<div data-role="fieldcontain">
			<label for="name">名称:</label>
			<form:input path="name" htmlEscape="false" maxlength="11" class="required"/>
		</div>
		<div data-role="fieldcontain">
			<fieldset data-role="controlgroup" data-type="horizontal" data-inline="true">
				<legend>护理项目:</legend>
				<input id="storeCareId" name="storeCare.id" type="hidden" value="${storeCardTemplateDuration.storeCare.id}"/>
				<input type="text" id="storeCareName" readonly
					value="${storeCardTemplateDuration.storeCare.care_type == 0? storeCardTemplateDuration.storeCare.care.name : storeCardTemplateDuration.storeCare.storeSelfCare.name}"
				 	name="storeCareName" class="required"/>
				 <div class="pbuttons">
				 	<input type="button" value="系统护理项目" data-inline="true" data-icon="plus" onclick="global.selectDialog('${ctx}/base/storeCare/storeCareData?type=0', this.value, 'storeCare')">
				 	<input type="button" value="店面护理项目" data-inline="true" data-icon="plus" onclick="global.selectDialog('${ctx}/base/storeCare/storeCareData?type=1', this.value, 'storeCare')">
				</div>
			</fieldset>
		</div>
		<div data-role="fieldcontain">
			<label for="duration">时段长度（月）:</label>
			<select id="duration" name="duration">
				<option value="1">一月</option>
				<option value="2">二月</option>
				<option value="3">三月</option>
				<option value="6">半年</option>
				<option value="12">一年</option>
			</select>
		</div>
		<div data-role="fieldcontain">
			<label for="retail_price">零售价（元）:</label>
			<form:input path="retail_price" htmlEscape="false" maxlength="10" class="required"/>
		</div>
		<div data-role="fieldcontain">
			<label for="real_cost">开卡优惠价（元）:</label>
			<form:input path="real_cost" htmlEscape="false" maxlength="50" class="required"/>
		</div>
	</form:form>
</body>
</html>
